<script type="text/javascript">
activeGraph = '';
function startGraph(name) {
	if ( activeGraph != '' ) {
		document.getElementById(activeGraph).className = 'graphTypeLink';
	}
	activeGraph = name;
	document.getElementById(name).className = 'graphActiveLink';
	document.getElementById('loadingStatus').style.display='';
	document.getElementById('graph').style.display='none';
}
function endGraph() {
	document.getElementById('loadingStatus').style.display='none';
	document.getElementById('graph').style.display='';
}
</script>

<div class="clearfix">
	<div class="floatLeft" style="border-right: solid 1px #ccc; padding-right: 15px;">
		<%= render(:partial => 'stats/game_filters') %>
	</div>
	
	<div class="floatLeft" style="border-right: solid 1px #ccc; padding: 0px 15px;">
		<div style="border-bottom: solid 1px #ccc;">
			<b>Graph Types</b>
		</div>
		
		<br />
		
		<ul>
		<% @per_day_values.each do |pd_value| -%>
			<li>
			<%=
	             link_to_remote(
	                 pd_value[:name].to_s, {
	                     :url => {
	                         :controller  => 'stats',
	                         :action      => @graph_action,
	                         :data_type   => pd_value[:data_type],
	                         :p1 => @p1.to_s,
	                         :p2 => @p2.to_s
	                     },
	                     :update => 'graph',
	                     :loading  => "startGraph('graph_#{pd_value[:data_type].to_s}');",
	                     :success  => "",
	                     :complete => "endGraph();",
	                     :failure  => "alert('Oops, try again.');"
	                 },
	                 {:id => "graph_#{pd_value[:data_type]}", :class => 'graphTypeLink'}
	             )
	         %>
	         </li>
		<% end -%>
		
		<% @total_values.each do |pd_value| -%>
			<li class="menuItem">
			<%=
	             link_to_remote(
	                 pd_value[:name].to_s, {
	                     :url => {
	                         :controller  => 'stats',
	                         :action      => @graph_action,
	                         :data_type   => pd_value[:data_type],
	                         :total => '1',
	                         :p1 => @p1.to_s,
	                         :p2 => @p2.to_s
	                     },
	                     :update => 'graph',
	                     :loading  => "startGraph('graph_#{pd_value[:data_type].to_s}_total');",
	                     :success  => "",
	                     :complete => "endGraph();",
	                     :failure  => "alert('Oops, try again.');"
	                 },
	                 {:id => "graph_#{pd_value[:data_type]}_total", :class => 'graphTypeLink'}
	             )
	         %>
	        </li>
		<% end -%>
		</ul>
	</div>
	
	<div class="floatLeft">
		<div id="loadingStatus" style="text-align: center; vertical-align: middle; display: none; background: #ececec; border: solid 1px #ccc; padding: 30px; width: 200px; height: 50px; margin-left: 300px; margin-top: 150px;">
			<img src="/images/loading.gif" />
			Generating Graph...
		</div>
		<div id="graph">
		</div>
	</div>
</div>